package com.wxc.api.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wxc.api.admin.entity.SysRoleMenuRelation;
import com.wxc.api.admin.mapper.SysRoleMenuRelationMapper;
import com.wxc.api.admin.service.ISysRoleMenuRelationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 角色-权限关联关系表 服务实现类
 * </p>
 *
 * @author baomidou
 * @since 2022-05-06
 */
@Service
public class SysRoleMenuRelationServiceImpl extends ServiceImpl<SysRoleMenuRelationMapper, SysRoleMenuRelation> implements ISysRoleMenuRelationService {

    @Autowired
    private SysRoleMenuRelationMapper sysRoleMenuRelationMapper;

    @Override
    public List<Integer> getInfo(Integer role_id) {
        QueryWrapper<SysRoleMenuRelation> wrapper = new QueryWrapper<>();
        wrapper.eq("role_id", role_id);
        List<SysRoleMenuRelation> sysRolePermissionRelation = sysRoleMenuRelationMapper.selectList(wrapper);

        return sysRolePermissionRelation
                .stream()
                .map(SysRoleMenuRelation::getMenuId)
                .collect(Collectors.toList());
    }


}
